<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>中国手机品牌销量柱状图</title>
  <!-- 引入 ECharts 库 -->
  <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
  <style>
    /* 设置图表容器的大小 */
    #main {
      width: 800px;
      height: 600px;
      margin: 50px auto;
    }
  </style>
</head>
<body>
  <!-- 图表容器 -->
  <div id="main"></div>
  <script>
    // 基于准备好的容器，初始化 ECharts 实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
      dataset: {
        source: [
          ['score', 'amount', 'product'],
          [95.2, 230000, '华为'],
          [88.5, 180000, '小米'],
          [77.3, 150000, 'vivo'],
          [66.4, 120000, 'OPPO'],
          [55.1, 80000, '荣耀'],
          [44.2, 70000, '一加'],
          [33.3, 50000, '真我'],
          [22.4, 30000, '努比亚'],
          [11.5, 20000, '魅族']
        ]
      },
      grid: { containLabel: true },
      xAxis: { name: '销量（万台）' },
      yAxis: { type: 'category' },
      visualMap: {
        orient: 'horizontal',
        left: 'center',
        min: 10,
        max: 100,
        text: ['高评分', '低评分'],
        dimension: 0,
        inRange: {
          color: ['#65B581', '#FFCE34', '#FD665F']
        }
      },
      series: [
        {
          type: 'bar',
          encode: {
            x: 'amount',
            y: 'product'
          }
        }
      ]
    };

    // 使用刚指定的配置项和数据显示图表
    myChart.setOption(option);
  </script>
</body>
</html>